package com.zhuiYun.project.api.trend.controller;

import com.zhuiYun.project.api.trend.entity.*;
import com.zhuiYun.project.api.trend.service.TrendsService;
import com.zhuiYun.project.common.controller.BaseController;
import com.zhuiYun.project.common.response.CommonResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

/**
 * @ClassName TrendsController
 * @Description TODO 动态（uniapp动态 ）
 * @Author gpd
 * @Date 2023-04-07 下午 04:42
 **/
@RestController
@CrossOrigin
@RequestMapping("/trends")
@Api(tags = "动态")
@Slf4j
public class TrendsController extends BaseController {

    @Autowired
    TrendsService trendsService;

    /**
    * @Author gpd
    * @Description 动态上传图片和视频（用于uniapp动态）
    * @Date 2023-04-08 上午 09:37
    * @Return CommonResult
    * @param  file
    */
    @RequestMapping("/uploadImageAndVideo")
    public CommonResult uploadImageAndVideo(MultipartFile file){
        return trendsService.uploadImageAndVideo(file);
    }

    /**
    * @Author gpd
    * @Description 新增用户发布的动态信息
    * @Date 2023-04-08 上午 10:18
    * @Return CommonResult

    */
    @PostMapping("/saveUserTrends")
    public CommonResult saveUserTrends(@RequestBody TrendContent trendContent){
        return CommonResult.ok(trendsService.saveUserTrends(trendContent));
    }

    /**
    * @Author gpd
    * @Description 查询所有用户发布的动态信息（用于uniapp动态）
    * @Date 2023-04-10 上午 11:43
    * @Return CommonResult
     * @param userId
     * @param trendId
     */
    @GetMapping("/getUserTrend")
    public CommonResult getUserTrend(Integer userId,Integer trendId){
        return trendsService.getUserTrend(userId,trendId);
    }


    /**
    * @Author gpd
    * @Description 新增一级动态评论（uniapp动态）
    * @Date 2023-04-10 下午 07:23
    * @Return
    * @param
    */
    @PostMapping("/saveFirstTrend")
    public CommonResult saveFirstTrend(@RequestBody TrendComment trendComment){
        return CommonResult.ok(trendsService.saveFirstTrend(trendComment));
    }

    /**
    * @Author gpd
    * @Description 新增二级动态评论（uniapp动态）
    * @Date 2023-04-11 下午 01:47
    * @Return com.zhuiYun.project.common.response.CommonResult

    */
    @PostMapping("/saveSecondTrend")
    public CommonResult saveSecondTrend(@RequestBody TrendComment trendComment){
        return CommonResult.ok(trendsService.saveSecondTrend(trendComment));
    }

    /**
    * @Author gpd
    * @Description 查询用户点赞表 根据用户id和动态id (uniapp 动态点赞查询)
    * @Date 2023-04-11 下午 07:31
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param tId
     * @param uId
    */
    @GetMapping("/getTrendThumbByUserIdAndTrendId")
    public CommonResult getTrendThumbByUserIdAndTrendId(Integer tId, Integer uId){
        return CommonResult.ok(trendsService.getTrendThumbByUserIdAndTrendId(tId,uId));
    }

    /**
    * @Author gpd
    * @Description 删除点赞表中点赞信息 (uniapp 动态取消点赞）
    * @Date 2023-04-11 下午 07:42
    * @Return com.zhuiYun.project.common.response.CommonResult
    */
    @DeleteMapping("/noThumbsUpState")
    public CommonResult noThumbsUpState(@RequestBody  TrendThumb trendThumb){
        return CommonResult.ok(trendsService.noThumbsUpState(trendThumb));
    }

    /**
    * @Author gpd
    * @Description 用户点赞 （uniapp）
    * @Date 2023-04-11 下午 07:57
    * @Return com.zhuiYun.project.common.response.CommonResult

    */
    @PostMapping("/thumbsUpState")
    public CommonResult ThumbsUpState(@RequestBody TrendThumb trendThumb){
        return CommonResult.ok(trendsService.ThumbsUpState(trendThumb));
    }

    /**
    * @Author gpd
    * @Description 删除动态一级评论和二级评论（uniapp动态）
    * @Date 2023-04-12 上午 09:20
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param  id
    */
    @DeleteMapping("/deleteTrendById")
    public CommonResult deleteTrendById(@RequestBody Integer id){
        return CommonResult.ok(trendsService.deleteTrendById(id));
    }

    /**
    * @Author gpd
    * @Description 查询用户发布的所有动态
    * @Date 2023-04-17 下午 07:53
    * @Return com.zhuiYun.project.common.response.CommonResult

    */
    @GetMapping("/getUserTrends")
    public CommonResult getUserTrends(Integer userId){
        return CommonResult.ok(trendsService.getUserTrends(userId));
    }

    /**
    * @Author gpd
    * @Description 查询用户选择的动态内容
    * @Date 2023-04-18 上午 09:12
    * @Return com.zhuiYun.project.common.response.CommonResult

    */
    @GetMapping("/getUserSelectTrend")
    public CommonResult getUserSelectTrend(Integer id,Integer userId){
        return CommonResult.ok(trendsService.getUserSelectTrend(id,userId));
    }

    /**
    * @Author gpd
    * @Description 动态评论点赞
    * @Date 2023-04-19 上午 10:31
    * @Return com.zhuiYun.project.common.response.CommonResult

    */
    @PostMapping("/thumbsCommentUpState")
    public CommonResult thumbsCommentUpState(@RequestBody TrendCommentThumb trendCommentThumb){
        return CommonResult.ok(trendsService.thumbsCommentUpState(trendCommentThumb));
    }

    /**
    * @Author gpd
    * @Description 动态评论取消点赞
    * @Date 2023-04-19 上午 10:45
    * @Return com.zhuiYun.project.common.response.CommonResult

    */
    @DeleteMapping("/noThumbsCommentUpState")
    public CommonResult noThumbsCommentUpState(@RequestBody TrendCommentThumb trendCommentThumb){
        return CommonResult.ok(trendsService.noThumbsCommentUpState(trendCommentThumb));
    }

    /**
    * @Author gpd
    * @Description 查询用户发布的所有动态
    * @Date 2023-04-19 下午 04:16
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param userId
    */
    @GetMapping("/getToUserThrend")
    public CommonResult getToUserThrend(Integer userId){
        return CommonResult.ok(trendsService.getToUserThrend(userId));
    }

    /**
    * @Author gpd
    * @Description 删除用户动态
    * @Date 2023-04-19 下午 04:34
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param id
    */
    @DeleteMapping("/delUserTrend")
    public CommonResult delUserTrend(@RequestBody Integer id){
        return CommonResult.ok(trendsService.delUserTrend(id));
    }

    /**
    * @Author gpd
    * @Description 修改动态内容状态 公开 （uniapp我的动态内容）
    * @Date 2023-04-20 上午 09:34
    * @Return com.zhuiYun.project.common.response.CommonResult
    * @param id
    */
    @PostMapping("/openTrend")
    public CommonResult openTrend(@RequestBody Integer id){
        return CommonResult.ok(trendsService.openTrend(id));
    }

    /**
    * @Author gpd
    * @Description 修改动态内容状态 私密uniapp我的动态内容）
     * * @Date 2023-04-20 上午 09:34
    * @Return com.zhuiYun.project.common.response.CommonResult
     * @param id

    */
    @PostMapping("/privateTrend")
    public CommonResult privateTrend(@RequestBody Integer id){
        return CommonResult.ok(trendsService.privateTrend(id));
    }
}
